package ph.com.gs3.formalistics.model.tables;

public class DocumentsTable extends AbstractDataTable {

	public static final String TAG = DocumentsTable.class.getSimpleName();

	// table name
	public static final String NAME = "Documents";

	// table columns
	public static final String COL_ID = "_id";
	public static final String COL_WEB_ID = "web_id";
	public static final String COL_SERVER = "server";
	public static final String COL_FORM_WEB_ID = "form_web_id";

	public static final String COL_TRACKING_NUMBER = "tracking_number";
	public static final String COL_STATUS = "status";
	public static final String COL_PROCESSOR = "processor_id";
	public static final String COL_REQUESTOR = "requestor_id";

	public static final String COL_DATE_CREATED = "date_created";
	public static final String COL_DATE_UPDATED = "date_updated";
	public static final String COL_DATE_COMMENTS_LAST_UPDATED = "comments_last_updated";

	public static final String COL_WORKFLOW_ID = "workflow_id";
	public static final String COL_NODE_ID = "current_node_id";

	public static final String COL_IS_STARRED = "is_starred";

	public static final String COL_FIELDS_ENABLED_JSON = "fields_enabled_json";
	public static final String COL_FIELDS_REQUIRED_JSON = "fields_required_json";
	public static final String COL_FIELDS_HIDDEN_JSON = "fields_hidden_json";

	public static final String COL_FIELDS_JSON = "fields_json";
	public static final String COL_ACTIONS_JSON = "actions_json";

	public static final String COL_DOCUMENT_RAW_JSON = "document_raw_json";

	public static final String COL_DOCUMENT_OWNER_ID = "document_owner_id";

	@Override
	public String[] getTableColumns() {
		return new String[] {

		COL_ID, COL_WEB_ID, COL_SERVER, COL_FORM_WEB_ID, COL_TRACKING_NUMBER, COL_STATUS,
		        COL_PROCESSOR, COL_REQUESTOR, COL_DATE_CREATED, COL_DATE_UPDATED,
		        COL_DATE_COMMENTS_LAST_UPDATED, COL_WORKFLOW_ID, COL_NODE_ID, COL_IS_STARRED,
		        COL_FIELDS_ENABLED_JSON, COL_FIELDS_REQUIRED_JSON, COL_FIELDS_HIDDEN_JSON,
		        COL_FIELDS_JSON, COL_ACTIONS_JSON, COL_DOCUMENT_RAW_JSON, COL_DOCUMENT_OWNER_ID

		};
	}

	@Override
	protected String getCreateTableQuery() {
		// @formatter:off
		return "CREATE TABLE " + NAME + "("
			+ COL_ID 							+ " INTEGER PRIMARY KEY AUTOINCREMENT, "
			+ COL_WEB_ID 						+ " TEXT NOT NULL, "
			+ COL_SERVER 						+ " TEXT NOT NULL, "
			+ COL_FORM_WEB_ID 					+ " TEXT NOT NULL, "
			+ COL_TRACKING_NUMBER 				+ " TEXT NOT NULL, "
			+ COL_STATUS 						+ " TEXT NOT NULL, "
			+ COL_PROCESSOR 					+ " TEXT NOT NULL, "
			+ COL_REQUESTOR 					+ " TEXT NOT NULL, "			
			+ COL_DATE_CREATED 					+ " TEXT NOT NULL, "
			+ COL_DATE_UPDATED 					+ " TEXT NOT NULL, "
			+ COL_DATE_COMMENTS_LAST_UPDATED 	+ " TEXT, "
			+ COL_WORKFLOW_ID 					+ " TEXT NOT NULL, "
			+ COL_NODE_ID 						+ " TEXT NOT NULL, "
			+ COL_IS_STARRED 					+ " TEXT NOT NULL, "
			+ COL_FIELDS_ENABLED_JSON			+ " TEXT NOT NULL, "
			+ COL_FIELDS_REQUIRED_JSON 			+ " TEXT NOT NULL, "
			+ COL_FIELDS_HIDDEN_JSON 			+ " TEXT NOT NULL, "
			+ COL_FIELDS_JSON 					+ " TEXT NOT NULL, "
			+ COL_ACTIONS_JSON 					+ " TEXT NOT NULL, "
			+ COL_DOCUMENT_RAW_JSON 			+ " TEXT NOT NULL, "
			+ COL_DOCUMENT_OWNER_ID 			+ " TEXT NOT NULL"
		+ "); ";
		// @formatter:on
	}

	@Override
	protected String getTableName() {
		return NAME;
	}

}
